<template>
  <div class="outer">
    <div class="user-info" v-if="token">
      <div class="user-name">
        <img :src="userInfo.img" alt />
        <span>欢迎您 {{ userInfo.username }}</span>
      </div>
      <div class="user-descri">
        <userDetail></userDetail>
      </div>
    </div>
    <div class="isLogin" v-else>
      <img src="./Info/login.png" alt="" />
      <h1>对不起，您还未登录！</h1>
    </div>
  </div>
</template>

<script>
import userDetail from "./Info/userDetail.vue"
// import api from "@/api"
import { mapState } from "vuex"

export default {
  name: "userInfo",
  data() {
    return {
      name: "Monday",
      userDetailData: {}
    }
  },
  computed: {
    ...mapState(["userInfo", "token"])
  },
  components: {
    userDetail
  },
  mounted() {
    // this.$api.getUserInfo().then((res) => {
    //   this.userDetailData = res.data.user
    //   // console.log(this.userDetailData)
    // })
    // console.log(this.userInfo)
  }
}
</script>

<style lang="less" scoped>
.outer {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(240, 240, 240, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  .user-info {
    background: #ffffff;
    box-shadow: 0 20px 40px 0 rgb(174 186 205 / 11%);
    border-radius: 5px;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .user-name {
      padding: 40px 0;
      display: flex;
      align-items: center;
      img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
      }
      span {
        margin-left: 10px;
      }
    }
    .user-descri {
      display: flex;
      justify-content: center;
      padding: 20px 0;
    }
  }
  .isLogin {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #ffffff;
    img {
      width: 250px;
      margin-bottom: 30px;
    }
  }
}
</style>
